import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
import Controls from '#cpt/temp/Controls'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const Page 					= $Lazy.load(()=>import('#tp/page/page-container'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// 搜索表单列表
		forms : [
			{ label: '接收时间',		names: ['start_at','end_at'], type:'date-range' },
		],
	}
	
	model = {}
	
	componentDidMount(){
		if(window.isInit){
			this.fetch()
		}
	}
	// paging
	fetch = () => $fn.fetch.call(this,'statistics/labFixedTimeCount',{ isIndex:true, callback: data => this.setState({ result: data }) })
	
	// 表单
	cols = [
		{ title: '条码号', 							dataIndex: 'spec_code', 			...$fn.table.spec_code },
		{ title: '姓名', 							dataIndex: 'patient_name', 			...$fn.table.name },
		{ title: '性别', 							dataIndex: 'sex_name', 				...$fn.table.sex },
		{ title: '年龄', 							dataIndex: 'age', 					...$fn.table.age },
		{ title: '受检人电话', 						dataIndex: 'patient_phone', 		...$fn.table.phone },
		{ title: '证件类型', 						dataIndex: 'card_type_name', 		...$fn.table.card_type },
		{ title: '证件号', 							dataIndex: 'card_no', 				...$fn.table.idcard },
		{ title: '送检标本', 						dataIndex: 'spec_type_name', 		width:150 },
		{ title: '标本状态', 						dataIndex: 'spec_traits_name', 		...$fn.table.status },
		{ title: '送检单位', 						dataIndex: 'hosp_name', 			width:200 },
		{ title: '接收时间', 						dataIndex: 'check_time', 			...$fn.table.time },
		{ title: '固定时间', 						dataIndex: 'bingli_coll_time', 		...$fn.table.time },
	]
	// 操作按钮
	controls = () => [
		Controls.exports.call(this, 'statistics/labCrisisCount'),			// 导出
	]
	
	render(){
		const { result } = this.state
		return (
			<>
				<Page title='病理固定时间录入' controls={this.controls()}>
					{/* 搜索 */}
					{ SearchForm.call(this) }
					{/* 表格 */}
					{
						Table.call(this,
						{isIndex:true,isInit:window.isInit,
							suffix: (
								<>
									<div className='ml10 g9'>总固定时间录入率 <b className='f14 c0'>{result?.fixed_proportion}</b></div>
                                    <div className='ml10 g9'>当前页固定时间录入率 <b className='f14 c0'>{result?.fixed_proportion_current}</b></div>
								</>
							)
						})
					}
				</Page>
			</>
		)
	}
}

export default Index